package com.wxg.user.service.impl;

import com.wxg.common.core.module.user.dao.mysql.User;
import com.wxg.common.core.module.user.dao.mysql.UserExample;
import com.wxg.common.core.module.user.po.UserAndAddressPo;
import com.wxg.user.dao.mysql.mapper.UserMapper;
import com.wxg.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: Administrator
 * @date: 2022/8/7 0:00
 * @desc:
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User queryById(Long userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public List<User> queryAllUser() {
        UserExample example = new UserExample();
        example.createCriteria().andDeleteTimeIsNull();
        example.setOrderByClause("create_time desc");
        return userMapper.selectByExample(example);
    }

    @Override
    public List<UserAndAddressPo> queryUserAndAddress(Long userId) {
        return userMapper.queryUserAndAddress2();
    }
}
